Ext.onReady(function(){
	   var d = new Date();
	   var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		var fileAttachment = Ext.create('component.file.attachment',{
            objectId: '',
            imageType: "6",
            contextPath:contextPath,
            colspan:2
       });
	   var fromPanelInfo = Ext.create('Ext.form.FormPanel',{
		    renderTo:Ext.getBody(),
		    titleAlign:'center',
	        title:'退房审批单',
		    border: true,
		    layout:{
		    	 type: 'table',
                 columns: 2,
                 tableAttrs: {　　//在这儿控制table标签中的Attrs属性
                     border: 1,
                     cellpadding: 5,
                     cellspacing: 1,
                     width: '95%',
                     align: 'center',
                     style: "border:1px solid gray;border-collapse:collapse;margin:0 auto;text-align:center;"
                 },
                 tdAttrs: {　　//控制td标签的属性，以上用法都是在ext的api中查到，同样的方式可以给tr添加属性
                     width: '100px',
                     height: '40px',
                     style: "padding:5px",
                     valign: 'middle'
                 }
		    },
			 items:[{
				    xtype:'displayfield',
				    fieldLabel: '合同编号',
				    name: 'signCode'
				},{
				    xtype:'displayfield',
				    fieldLabel: '签约总价(元)',
				    name: 'signAmount'
				},{
				    xtype:'displayfield',
				    fieldLabel: '房号',
				    name: 'roomName'
				},{
				    xtype:'displayfield',
				    fieldLabel: '客户姓名',
				    name: 'customerName'
				},{
				    xtype:'displayfield',
				    fieldLabel: '签约日期',
				    name: 'didTime'
				},{
				    xtype:'displayfield',
				    fieldLabel: '签约明细',
				    name:'signedDetail'
				},{
					 xtype:'numberfield',
					 fieldLabel: '没收违约金(元)',
					 allowDecimals:false,
					 allowNegative:false,
					 decimalPrecision:0,
					 maxValue:1000000000,
					 minValue:1,
					 id:'liquidat',
					 colspan:2,
					 allowBlank:specialFlowFlag,
			    		 blankText:'不能为空',
			    		 hidden:specialFlowFlag
				},{
				    xtype:'textarea',
				    fieldLabel: '退房原因',
				    name: 'remark',
				    width:900,
				    align: 'left',
				    id:'reason',
				    colspan:2,
				    allowBlank:false,
			    	blankText:'不能为空'
				},{
				    xtype:'displayfield',
				    fieldLabel: '经纪人',
				    name: 'userName'
				},{
				    xtype:'displayfield',
				    fieldLabel: '申请日期',
				    value: str
				},fileAttachment],
				dockedItems: [{
		            xtype: 'toolbar',
		            dock: 'bottom',
		            ui: 'footer',
		            layout: {
		                pack: 'center'
		            },
		            items: [{
		                minWidth: 80,
		                text: '提交审核',
		                id:'save_button',
		                iconCls:'icon-save',
		                handler:function(){
		                	var form = fromPanelInfo.getForm();
		                	var fileUrlArr = fileAttachment.getFileArrs();
		                	if(form.isValid()){
		                		var params={
			                			'signedId':signedId,
			                			'remark':Ext.getCmp("reason").getValue(),
			                			fileUrlArr:fileUrlArr,
			                			imageType: "6",
			                			'token':token,
			                			'liquidat':Ext.getCmp("liquidat").getValue()
			                	};
		                		Ext.getCmp('save_button').setVisible(false);
		                		Ext.Msg.wait("正在处理，请稍等...","");
		                		Ext.Ajax.request({
			                		url:contextPath+'/customer/signed/submitCheckOut',
			                		params:params,
			                		callback: function (options, success, response) {
			                			 Ext.Msg.hide();
			                			 var obj = JSON.parse(response.responseText);
			                			 if(obj.res=="1"){
			                				  Ext.MessageBox.alert("系统提示", "提交成功! ", function(but) {  
			                					  var tabKey = "cto"+signedId;
					 						      parent.TabControlRemove(tabKey);
			    				                });  
			    						 }else{
			    							 token = obj.obj;
			    							 Ext.MessageBox.alert("系统提示",obj.resMsg); 
			    							 Ext.getCmp('save_button').setVisible(true);
			    						 }
			                		}
			                	});
		                		
		                	}
		                }
		            },
		            {
						xtype: "button",
						text : "返回",
						id: "btn_back",
						name: "btn_back",
						icon : contextPath + '/resources/ExtJSicons/shape_move_backwards.png',
						listeners: {
							click: function(){
								var tabKey = "cto"+signedId;
								parent.TabControlRemove(tabKey);
							}
						}
					}]
		        }
		        ]
	   });
	   
	   fromPanelInfo.getForm().load({
			url:contextPath+'/customer/signed/loadCheckOutInfo',
			params:{'signedId':signedId},
			success:function(form, action){
				var obj = action.result.data;
				var result=Ext.JSON.decode(obj);
				var showHerf = "<a href='javascript:parent.openMenu(\"0\",\"sig_"+signedId+"\",\"\",\"签约详情\",\"/customer/signed/toView?id="+signedId+"&returnUrl=,marketing,pin,index\")' style='cursor:pointer'>签约明细</a>";
				fromPanelInfo.getForm().setValues(result);
				fromPanelInfo.getForm().findField("signedDetail").setValue(showHerf);
			},   
			failure: function(form, action) {
		        Ext.Msg.alert("加载失败", action.result.errorMessage);
		    }

		});
	  
});